package com.deductive.web.disposition.algorithm;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.deductive.common.core.controller.BaseController;
import com.deductive.common.core.domain.AjaxResult;
import com.deductive.common.core.page.TableDataInfo;
import com.deductive.domain.algorithm.AlgorithmHerbalMaterialQuality;
import com.deductive.service.algorithm.AlgorithmHerbalMaterialQualityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("algorithmHerbalMaterialQuality")
@Api(tags = "药材品量管理")
public class AlgorithmHerbalMaterialQualityController extends BaseController {

    @Resource
    private AlgorithmHerbalMaterialQualityService ahmqService;

    @GetMapping("/pageQuery")
    @ApiOperation("分页查询")
    public TableDataInfo selectAll(AlgorithmHerbalMaterialQuality ahmq) {
        startPage();
        List<AlgorithmHerbalMaterialQuality> list = this.ahmqService.list(new QueryWrapper<>(ahmq));
        return getDataTable(list);
    }

    @GetMapping("{id}")
    @ApiOperation("根据id查询")
    public AjaxResult selectOne(@PathVariable Integer id) {
        return success(this.ahmqService.getById(id));
    }

    @PostMapping
    @ApiOperation("新增数据")
    public AjaxResult insert(@RequestBody AlgorithmHerbalMaterialQuality ahmq) {
        return success(this.ahmqService.save(ahmq));
    }

    @PutMapping
    @ApiOperation("修改数据")
    public AjaxResult update(@RequestBody AlgorithmHerbalMaterialQuality ahmq) {
        return success(this.ahmqService.updateById(ahmq));
    }

    @DeleteMapping
    @ApiOperation("删除数据")
    public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
        return success(this.ahmqService.removeByIds(idList));
    }
}
